<?php

    function get_default_or_create_fav_list($user_id_or_obj) {
        $srv = new service_l_favorite();
        $new_list = NULL;
        if (($new_list = $srv->get_default_list($user_id_or_obj)) === NULL) {
            $new_list = $srv->create_list($user_id_or_obj);
        }
        unset ($srv);
        return $new_list;
    }

    function get_all_fav_items($list_id_or_obj){
        $srv = new service_l_favorite();
        $items = $srv->get_items($list_id_or_obj);
        unset ($srv);
        return $items;
        
    }

    function is_valid_fav_entry($list_id,$prod_id){
        $query =
        get_instance()->db
                ->where("favorite_list_id",$list_id)
                ->where("product_id",$prod_id)
                ->get("favorite_lists_products");
        if($query->num_rows()>0){
            return TRUE;
        }else{
            return FALSE;
        }

    }

?>
